//自己实现tostring
public class TestDemo4 {
    public static String myToString(int[] arr){
        String str = "[";
        for(int i = 0; i < arr.length; ++i){
            if (i < arr.length - 1){
                str += arr[i] + "," + " ";
            }
            else {
                str += arr[i] + " ";
            }
        }
        str += "]";
        return str;
    }

    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5};
        String str = myToString(arr);
        System.out.println(str);
    }
}
